Skip to content

Conversation

@geoffw0
Copy link
Contributor

@geoffw0 geoffw0 commented Aug 14, 2025

Add a type inference test case resembling what I think happens in real world calls to PathBuf.canonicalize, affecting the function of our rust/path-injection barriers flow states. My understanding is that the Deref trait on PathBuf makes it behave much like a pointer to / slice of a Path, and type inference fails to work through what I believe is an implicit dereference on line 2597 of the test.

The lack of support for the Deref trait is already a known problem, but I think it's good to have test coverage resembling real world patterns that matter to our analysis.

@hvitved

Copilot AI review requested due to automatic review settings August 14, 2025 08:02
@geoffw0 geoffw0 requested a review from a team as a code owner August 14, 2025 08:02
@geoffw0 geoffw0 added no-change-note-required This PR does not need a change note Rust Pull requests that update Rust code labels Aug 14, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a test case to demonstrate type inference limitations with the Deref trait in Rust, specifically testing a pattern resembling PathBuf.canonicalize() which is relevant to path injection analysis.

  • Adds a simplified model of Path and PathBuf types with canonicalize method
  • Implements Deref trait for PathBuf to demonstrate implicit dereference behavior
  • Tests type inference through both direct method calls and calls via Deref trait

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
main.rs Adds new path_buf module with test types and function demonstrating Deref trait limitations
type-inference.expected Updates expected test output with new type inference results for the added test cases

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@hvitved
Copy link
Contributor

hvitved commented Aug 15, 2025

My understanding is that the Deref trait on PathBuf makes it behave much like a pointer to / slice of a Path, and type inference fails to work through what I believe is an implicit dereference on line 2597 of the test.

Did you mean line 2601?

@geoffw0
Copy link
Contributor Author

geoffw0 commented Aug 18, 2025

Did you mean line 2601?

Yes. :)

@geoffw0 geoffw0 merged commit 4eea443 into github:main Aug 18, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-change-note-required This PR does not need a change note Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants